package algorithm;


import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

/**
 * @Auther: ssk
 * @Date: 2019/1/18 20:09
 * @Description:
 * @link https://www.zhixincode.com/contest/6/problem/E?problem_id=76
 * dijkstra  迪杰斯塔拉
 */
class Cle{
    public double x;
    public double y;
    public double r;

    public Cle(double x, double y, double r) {
        this.x = x;
        this.y = y;
        this.r = r;
    }

    public Cle() {
    }
    public double getdis(Cle cle){
        double dis= Math.sqrt(Math.pow(cle.x-this.x,2)+Math.pow(cle.y-this.y,2)) - this.r - cle.r;
        return dis>0?dis:0;
    }
}
class Node{
    public double dis;
    public int index;

    public Node(double dis, int index) {
        this.dis = dis;
        this.index = index;
    }

    public Node() {
    }
}
public class Main {
    static  int n,a,b,c1,c2;
    static double[][] dis;
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        n=scanner.nextInt();
        a=scanner.nextInt();
        b=scanner.nextInt();
        c1=scanner.nextInt();
        c2=scanner.nextInt();
        Cle cle[] = new Cle[n+3];
        for (int i=0;i<n;i++) {
            cle[i] = new Cle(scanner.nextInt(),scanner.nextInt(),scanner.nextInt());
        }
        dis = new double[n+3][];
        for (int i=0;i<n+3;i++) {
            dis[i] = new double[n+3];
        }
        for (int i=0;i<n;i++){
            dis[i][i]=0;
            for (int j=i+1;j<n;j++){
                dis[i][j]=cle[i].getdis(cle[j]);
                dis[j][i]=dis[i][j];
            }
        }
        dis[n][n+1] = Math.abs(c2-c1)/Math.sqrt(Math.abs(a*a+b*b));
        dis[n+1][n]=dis[n][n+1];
        for(int i=0;i<n;i++){
            double dist = Math.abs(a*cle[i].x+b*cle[i].y+c1)/Math.sqrt(Math.abs(a*a+b*b))-cle[i].r;
            if (dist<0) dist=0;
            dis[n][i] = dist;
            dist = Math.abs(a*cle[i].x+b*cle[i].y+c2)/Math.sqrt(Math.abs(a*a+b*b)) - cle[i].r;
            if (dist<0) dist=0;
            dis[n+1][i] = dist;
            dis[i][n]=dis[n][i];
            dis[i][n+1]=dis[n+1][i];
        }
        boolean vis[] = new boolean[n+3];
        Arrays.fill(vis,false);

        double[] diss = new double[n+3];
        Arrays.fill(diss,Double.MAX_VALUE);
        diss[n]=0;
        PriorityQueue<Node> queue = new PriorityQueue<Node>(
                (node1,node2)->node1.dis-node2.dis>0?1:-1
        );
        queue.add(new Node(0,n));
        while (!queue.isEmpty()) {
            Node u = queue.poll();
            if (vis[u.index]) continue;
            vis[u.index]=true;
            for (int i=0;i<n+2;i++) {
                if (vis[i]!=true&&diss[i]>u.dis+dis[u.index][i]) {
                    diss[i]=u.dis+dis[u.index][i];
                    queue.add(new Node(diss[i],i));
                }
            }


        }
        System.out.println(diss[n+1]);
        scanner.close();
    }

}
